package asia.kalin.controller;

import asia.kalin.service.IDetectionResultService;
import asia.kalin.domain.ao.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: Kalin
 * @Name：DetectionResultController
 * @Date: 2025/3/11
 * @description
 */

@RestController
@RequestMapping("/detectionResult")
@RequiredArgsConstructor
public class DetectionResultController {

    private final IDetectionResultService detectionResultService;

    /**
     * 根据类型查询检测结果
     * @param
     * @return Result
     */
    @GetMapping("/queryByType")
    public Result queryDetectionResultByTypeList(){
        return detectionResultService.queryByTypeList();
    }

    /**
     * 跟据resultId查询详细内容
     * @param resultId
     * @return Result
     */
    @GetMapping("/queryById")
    public Result queryDetectionResultByIdOne(@RequestParam String resultId){
        return detectionResultService.queryByIdOne(resultId);
    }

    /**
     * 根据摄像头上传的图片进行检测分析 生成检测内容
     * @param file 用户上传的图片
     * @return Result
     */
    @PostMapping("/uploadImgGenerates")
    public Result generatesDetectionResults(MultipartFile file,String cameraId){
        if(file == null || file.isEmpty())
            return new Result<>(1,"上传文件为空",null);
        return detectionResultService.generatesDetectionResultsByAI(file,cameraId);
    }

}
